package com.yangming.springboot.deepin.playTest;

import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockExample {

    private int a = 0;
    ReentrantLock lock = new ReentrantLock();
    public void wirter(){
        lock.lock();
        try{
            a++;
        }finally{
            lock.unlock();
        }
    }
    public void reader(){
        lock.lock();
        try {
            int i = a;
        }finally{
            lock.unlock();
        }
    }

}
